﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommunityServer.WebServices.Blogs;

namespace CommunityServer.Blogs
{
    class Posts
    {
        BlogsService oBlogService = new BlogsService("http://192.168.1.113/", "pronychgary", "4vgw1bkx");

        private void AddBlogPost()
        {
            Blog blog = oBlogService.GetBlog("news");
            BlogPost post = new BlogPost();
            post.Title = "REST post";
            post.Body = "this is the body of this post.";
            post.Date = DateTime.Now;
            post.Keywords.Add("test");
            ;

            oBlogService.AddBlogPost(post, blog.Id);
        }

        private List<BlogPost> GetBlogPosts()
        {
            Blog blog = oBlogService.GetBlog("news");

            return oBlogService.GetBlogPosts(blog.Id);

        }

        private static void DeleteBlogPost()
        {
            //BlogsService service = new BlogsService("http://192.168.1.113:8008/", "pronychgary", "4vgw1bkx");

            //Blog blog = service.GetBlog("news");
            //BlogPostQuery query = new BlogPostQuery();
            //query.BlogIds  = blog.Id;
            //query.Keywords.Add("Sample"); 

            //List posts = service.GetBlogPosts(query); 
            //foreach (BlogPost post in posts) 
            //    service.DeleteBlogPost(post.Id);
        }
 
    }
}
